package org.example.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.example.utils.DateUtils;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.stereotype.Component;

/**
 *
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println("insert开始属性填充");
        this.strictInsertFill(metaObject,"gmtCreate", String.class,DateUtils.getDateTime());
        this.strictInsertFill(metaObject,"lastTime", String.class,DateUtils.getDateTime());
        this.strictInsertFill(metaObject,"status", Integer.class,1);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        System.out.println("update开始属性填充");
        this.strictUpdateFill(metaObject,"gmtModified", String.class,DateUtils.getDateTime());
        this.strictUpdateFill(metaObject,"lastTime", String.class,DateUtils.getDateTime());
    }
}
